﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional

namespace PlatformUW.EntityFramework.Migrations
{
    /// <inheritdoc />
    public partial class cm1 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase()
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Players",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Account = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    AccountType = table.Column<string>(type: "varchar(10)", maxLength: 10, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DateCreated = table.Column<DateTime>(type: "datetime(6)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Players", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Characters",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    NickName = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Classes = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Level = table.Column<int>(type: "int", nullable: false),
                    DateCreated = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    PlayerId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Characters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Characters_Players_PlayerId",
                        column: x => x.PlayerId,
                        principalTable: "Players",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.InsertData(
                table: "Players",
                columns: new[] { "Id", "Account", "AccountType", "DateCreated" },
                values: new object[,]
                {
                    { new Guid("d4aedb61-578c-4c2d-947d-ca098d7f08e8"), "LiShi", "Free", new DateTime(2025, 6, 4, 15, 30, 51, 156, DateTimeKind.Local).AddTicks(2041) },
                    { new Guid("f5d4800b-feef-4bd7-a2d4-77581a75671d"), "ZhangSan", "Free", new DateTime(2025, 6, 4, 15, 30, 51, 156, DateTimeKind.Local).AddTicks(2033) }
                });

            migrationBuilder.InsertData(
                table: "Characters",
                columns: new[] { "Id", "Classes", "DateCreated", "Level", "NickName", "PlayerId" },
                values: new object[,]
                {
                    { new Guid("70315086-7738-4ee7-8ba9-6b9840100062"), "Palain", new DateTime(2025, 6, 4, 15, 30, 51, 156, DateTimeKind.Local).AddTicks(2667), 99, "Superman", new Guid("d4aedb61-578c-4c2d-947d-ca098d7f08e8") },
                    { new Guid("8c7884c5-c0f2-4c4d-829d-9c336671e5af"), "Death Knight", new DateTime(2025, 6, 4, 15, 30, 51, 156, DateTimeKind.Local).AddTicks(2665), 90, "Batman", new Guid("d4aedb61-578c-4c2d-947d-ca098d7f08e8") },
                    { new Guid("8f39eac9-0936-4462-ab2f-fdd917ac5771"), "Mage", new DateTime(2025, 6, 4, 15, 30, 51, 156, DateTimeKind.Local).AddTicks(2659), 99, "Code Man", new Guid("f5d4800b-feef-4bd7-a2d4-77581a75671d") },
                    { new Guid("b04ccd92-53f7-4034-bba3-f90181e6db7f"), "Druid", new DateTime(2025, 6, 4, 15, 30, 51, 156, DateTimeKind.Local).AddTicks(2664), 80, "Spider Man", new Guid("f5d4800b-feef-4bd7-a2d4-77581a75671d") },
                    { new Guid("de2e818f-bef4-4921-865b-d0a90d0f2167"), "Warrior", new DateTime(2025, 6, 4, 15, 30, 51, 156, DateTimeKind.Local).AddTicks(2662), 90, "Iron Man", new Guid("f5d4800b-feef-4bd7-a2d4-77581a75671d") }
                });

            migrationBuilder.CreateIndex(
                name: "IX_Characters_NickName",
                table: "Characters",
                column: "NickName",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Characters_PlayerId",
                table: "Characters",
                column: "PlayerId");

            migrationBuilder.CreateIndex(
                name: "IX_Players_Account",
                table: "Players",
                column: "Account",
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Characters");

            migrationBuilder.DropTable(
                name: "Players");
        }
    }
}
